#pragma once
#ifndef PROTO_SOCKBASE_H
#define PROTO_SOCKBASE_H

#include <vector>
#include "common.h"
#include "google/protobuf/message.h"

//定义通用类型

typedef unsigned char uint8_t;
typedef unsigned uint32_t;
typedef unsigned short uint16_t;

using namespace google::protobuf;

#pragma pack(push) //保存旧的对齐方式
#pragma pack(1)

struct PackHeader
{
	char sign[4];
	uint32_t len;
};

struct ProtoNameHeader
{
	uint16_t namelen;
	char name[1];
};

#pragma pack(pop) //恢复对齐方式

class ProtoSockBase
{
public:
	//接收收到的报文
	static int ReceiveProto(int fd, std::vector<Message *> & msglist);

	//发送报文
	static int SendProto(int fd, Message * msg);

    static int PrintPeerName(int fd);
};


#endif //PROTO_SOCKBASE_H
